<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <button>点我</button>
    <script>
      const objIds = []
      document.addEventListener('click', function () {
        const { gid = 'GKX_SB0213' } = {}
        const obj = {
          gid,
          highlight: true,
        }
        objIds.push(obj)
        console.log(JSON.stringify(objIds))
      })
      /* 清空 */
      document.querySelector('button').addEventListener('click', function (e) {
        e.stopPropagation()
        objIds.length = 0
        console.log(JSON.stringify(objIds))
      })
    </script>
  </body>
</html>
